#include "island.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

Island::Island(unsigned int width_, unsigned int height_,unsigned int animalscount)
    : width(width_), height(height_), AnimalsCount(animalscount)
{
    Animals = NULL;
    Animals = new Animal[AnimalsCount];
    for(int i = 0; i < AnimalsCount; i ++)
        Animals[i].MaxSquare = Square(width-1, height-1);
}

Island::~Island()
{
    free(Animals);
}

void Island::MoveAnimals()
{
}

void Island::CountAnimals()
{
}

void Island::PrintState()
{
    cout << ".";
    for(int i = 0; i < width; i++)
        cout << "-----." ;
    cout << endl;
    for(int i = 0; i < height; i++)
    {
        cout << "|";
        for(int j = 0; j < width; j++)
        {
            int ac = 0;
            for(int k = 0; k < AnimalsCount; k++)
                if(Animals[k].CurrentSquare.X == j && Animals[k].CurrentSquare.Y == i)
                    ac ++;
            if(ac)
                printf("R%4d|",ac);
            else
                cout << "     |" ;
        }
        cout << endl;
        cout << "|";
        for(int j = 0; j < width; j++)
        {
            cout << "     |" ;
        }
        cout << endl;
        cout << ".";
        for(int i = 0; i < width; i++)
            cout << "-----." ;
        cout << endl;
    }

}
